<?php
date_default_timezone_set("Asia/Shanghai");
require './lib/commom.php';
$xxxml			=	ROOT_PATH."/xml.xml";
$now	=	date("H:i");
$bid	=	(int)$_GET["bid"]; 
$bbid	=	floor($bid/1000);
$cachexmlname	=	ROOT_PATH."/cached/b/xml/".$bbid."/".$bid.".xml";
$path	=	"cached/b/xml/".$bbid."/";
path($path);
$openurl	=	"http://yxxzz.vicp.net/i.php?i=3z".$bid.".html";
$file	=	curl($openurl);
$file 	=	iconv("GBK", "UTF-8//IGNORE", $file);
$rule		=	"|<a href=\"/3z[0-9]+-([0-9]+).html\" title=\".+?\">(.+?)</a>|U";
preg_match_all($rule,$file,$matchs);
$rule1		=	"|<a title=\".+?\" href=\"/3z[0-9]+-([0-9]+).html\">(.+?)</a>|U";
preg_match_all($rule1,$file,$matchs1);
$count= count($matchs[1]);
$count1= count($matchs1[1]);
$b	=	$count;
for($i=0;$i<$count1;$i++){
	$matchs[0][$b+$i] = $matchs1[0][$i];
	$matchs[1][$b+$i] = $matchs1[1][$i];
	$matchs[2][$b+$i] = $matchs1[2][$i];
	}
array_multisort($matchs["1"],   SORT_NUMERIC,   SORT_ASC,  $matchs["2"],   SORT_STRING,   SORT_ASC);  
print_r($matchs);
$xml = new SimplexmlElement($xxxml,NULL,TRUE);
$books	=	$xml->addChild('books');
$count= count($matchs[1]);
		for($i=0;$i<$count;$i++){
	$charts	=	$xml->books->addChild('charts');
	$charts->addChild('id',xmlencode($matchs[1][$i]));
	$charts->addChild('title',xmlencode($matchs[2][$i]));
	$lastname	=	$matchs[2][$i];
	}
	echo $lastname;
	$xml->asXML($cachexmlname);
?>